home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 90 / CD Actual 90.iso / Software3D / K-3D / k3d-0.4.2.1 / shaders / k3d_bubbles.sl < prev    next >
Encoding:
Text File  |  2004-07-23  |  843 b   |  28 lines

  1. /*
  2.  * FEbubbles.sl
  3.  * 
  4.  * A simple semi-sphere carpet displacment
  5.  * Felipe Esquivel  felipeer@hotmail.com
  6.  * Nov 2000
  7.  * 
  8.  */
  9. displacement k3d_bubbles(float radius = 0.5;   /* values between -0.5 and 0.5          */
  10.                        float Kmag = 1;       /* scale                                */
  11.                        float frequency = 1;) /* number of bubbles per linear surface */
  12.  
  13. {
  14.  float distance2point;
  15.  point myCenter = (0, 0, 0);
  16.  float magnitud = 0;
  17.  
  18.  float smod = mod((s) * frequency, 1) - 0.5;
  19.  float tmod = mod((t) * frequency, 1) - 0.5;
  20.  point myPoint = (smod, 0, tmod);
  21.  distance2point = distance(myPoint, myCenter);
  22.  if (distance2point <= radius) 
  23.     magnitud = sqrt((radius * radius) - (distance2point * distance2point));
  24.  
  25.  P += Kmag * magnitud * normalize(N);
  26.  N = calculatenormal(P);
  27. }
  28.